//
//  MenuController.m
//  autoHome
//
//  Created by MS on 15/9/9.
//  Copyright (c) 2015年 qf1523. All rights reserved.
//

#import "MenuController.h"
#import "forumViewController.h"
@interface MenuController ()<UITableViewDataSource,UITableViewDelegate>
{
   
    NSMutableArray *_meArr;
    NSMutableArray *mindexArr;
}

@end

@implementation MenuController

- (void)viewDidLoad {
    [super viewDidLoad];
     NSArray *mArr = @[@"全部",@"汽车之家十年",@"媳妇当车模",@"美人“记”",@"论坛名人堂",@"论坛讲师",@"精挑细选",@"现身说法",@"高端阵地",@"电动车",@"汇买车",@"行车点评",@"超级试驾员",@"海外购车",@"经典老车",@"妹子选车",@"优惠购车",@"原创大片",@"顶配风采",@"改装有理"];
//    [self creatMenuView:mArr];
    // Do any additional setup after loading the view.
}

-(void)creatMenuView:(NSArray *)mArr
{
    _meArr = [[NSMutableArray alloc] init];
    
   
    
     NSArray *aaa = @[@(0),@(233),@(104),@(110),@(172),@(230),@(121),@(106),@(118),@(210),@(199),@(198),@(168),@(113),@(109),@(191),@(196),@(107),@(105),@(122)];
    
    mindexArr = [[NSMutableArray alloc] initWithArray:aaa];
    [_meArr addObjectsFromArray:mArr];
    
    _mtableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, 240, self.view.frame.size.height) style:UITableViewStylePlain];
    _mtableView.delegate = self;
    _mtableView.dataSource = self;
    _mtableView.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:_mtableView];
    UILabel *headLabel = [[UILabel alloc] init];
    headLabel.frame = CGRectMake(0, 0, 240, 64);
    headLabel.backgroundColor = [UIColor whiteColor];
    headLabel.text = @"精选分类";
    headLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:headLabel];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame =CGRectMake(200, 20, 40, 30);
    [btn setTitle:@"关闭" forState:UIControlStateNormal];
    
    [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(closeMenu:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    

}
-(void)closeMenu:(UIButton*)btn
{
    NSLog(@"close~~");
    [UIView animateWithDuration:0.3 animations:^{
        
        self.view.frame = CGRectMake(self.view.frame.size.width+240, 0, 240, self.view.frame.size.height);
        
    } completion:^(BOOL finished) {
        
    }];
    self.isClose = @"y";
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _meArr.count;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"aaa"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"aaa"];
    }
    cell.textLabel.text = _meArr[indexPath.row];
    
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    forumViewController *f = [forumViewController sharedViewCtr];

   
    [UIView animateWithDuration:0.3 animations:^{
        
        self.view.frame = CGRectMake(self.view.frame.size.width+240, 0, 240, self.view.frame.size.height);
        
        
    } completion:^(BOOL finished) {
        
    }];
}


@end
